home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: April 27, 1997
- // Author: db
- //
- // Description:
- // This script creates a bookmark editor for the set editor
- //
-
- global proc setEdBookmarkMakeMenuBar(string $setEd)
- {
- menu -l "Edit" -aob true;
- menuItem
- -l "Add Bookmark"
- -command ("setEdBookmarkAddCallback " + $setEd + " later");
- menuItem -optionBox true -l "Add Bookmark Option Box"
- -command ("setEdBookmarkAddCallback " + $setEd + " first");
- menuItem
- -l "Delete Bookmark"
- -command ("setEdBookmarkDeleteCallback " + $setEd);
- menuItem
- -l "Rename Bookmark..."
- -command ("setEdBookmarkRenameCallback " + $setEd);
- }
-
-
- global proc setEdBookmarkUpdate(string $setEd)
- {
- // Unique names for the widgets for this
- // instance of the bookmark editor
- string $bmeWindow = ($setEd + "BMEDWindow");
- string $bmeForm = ($setEd + "BMEForm");
- string $bmeListForm = ($setEd + "BMEListForm");
- string $bmeTextList = ($setEd + "BMETextList");
-
- if (`window -exists $bmeWindow`)
- {
- setParent ($bmeWindow + "|" + $bmeForm + "|" + $bmeListForm);
-
- if (`textScrollList -exists $bmeTextList`)
- {
- deleteUI $bmeTextList;
- }
-
- formLayout -e -visible false $bmeListForm;
-
- textScrollList -height 100
- -allowMultiSelection no
- -allowAutomaticSelection yes
- $bmeTextList;
-
- formLayout -e
- -attachForm $bmeTextList top 0
- -attachForm $bmeTextList left 0
- -attachForm $bmeTextList bottom 0
- -attachForm $bmeTextList right 0
- $bmeListForm;
-
- textScrollList -e -selectCommand ("setEdBookmarkSelectCallback " + $setEd) $bmeTextList;
- textScrollList -e -doubleClickCommand ("setEdBookmarkRenameCallback " + $setEd) $bmeTextList;
- textScrollList -e -deleteKeyCommand ("setEdBookmarkDeleteCallback " + $setEd) $bmeTextList;
-
- string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
- for ($bookmark in $bookmarks)
- {
- textScrollList -e -a $bookmark $bmeTextList;
- }
-
- formLayout -e -visible true $bmeListForm;
-
- setParent ..;
- }
- }
-
- global proc setEdBookmarkCreateUI(string $setEd)
- {
- // Unique names for the widgets for this
- // instance of the bookmark editor
- string $bmeWindow = ($setEd + "BMEDWindow");
- string $bmeForm = ($setEd + "BMEForm");
- string $bmeListForm = ($setEd + "BMEListForm");
- string $bmeButtonForm = ($setEd + "BMEButtonForm");
- string $bmeAddButton = ($setEd + "BMEAddButton");
-
- // Create a new window
- window
- -title "Bookmarks"
- -width 140 -height 400
- -menuBar true
- -minimizeButton true
- -maximizeButton false
- $bmeWindow;
-
- setEdBookmarkMakeMenuBar $setEd;
-
- formLayout $bmeForm;
- formLayout $bmeListForm;;
- setParent ..;
- formLayout -height 30 $bmeButtonForm;
-
- button -l "Add Bookmark" -c ("setEdBookmarkAddCallback " + $setEd + " later") $bmeAddButton;
-
- formLayout -e
- -attachForm $bmeListForm right 0
- -attachForm $bmeListForm left 0
- -attachForm $bmeListForm top 0
- $bmeForm;
-
- formLayout -e
- -attachForm $bmeButtonForm right 0
- -attachForm $bmeButtonForm left 0
- -attachForm $bmeButtonForm bottom 0
- $bmeForm;
-
- formLayout -e
- -attachControl $bmeListForm bottom 0 $bmeButtonForm
- $bmeForm;
-
- formLayout -e
- -af $bmeAddButton top 0
- -af $bmeAddButton left 0
- -af $bmeAddButton bottom 0
- -af $bmeAddButton right 0
- $bmeButtonForm;
-
- setEdBookmarkUpdate $setEd;
- showWindow $bmeWindow;
- }
-
-
- global proc string getSelectedBookmark(string $setEd)
- {
- // Unique name for the text scroll list
- string $bmeTextList = ($setEd + "BMETextList");
-
- string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
- int $item[1] = `textScrollList -q -selectIndexedItem $bmeTextList`;
- string $bookmarkName = $bookmarks[$item[0]-1];
-
- return $bookmarkName;
- }
-
- global proc setEdBookmarkSelectCallback(string $setEd)
- //
- // Callback for selecting set editor bookmarks.
- //
- {
- string $bookmarkName = getSelectedBookmark($setEd);
- setEditor -edit -useBookmark $bookmarkName $setEd;
- }
-
-
- global proc setEdBookmarkDeleteCallback(string $setEd)
- //
- // Callback for deleting set editor bookmarks.
- //
- {
- string $bookmarkName = getSelectedBookmark($setEd);
- delete $bookmarkName;
- setEdBookmarkUpdate $setEd;
- }
-
-
- global proc setEdBookmarkRenameMenuCallback(string $setEd, string $oldBookmarkName)
- //
- // Callback for renaming set editor bookmarks.
- // (invoked from the menu option box)
- //
- {
- string $result = `promptDialog
- -title "Rename Bookmark"
- -message "Rename Bookmark:"
- -text $oldBookmarkName
- -defaultButton "OK"
- -button "OK"
- -button "Cancel"`;
- if ($result == "OK")
- {
- string $newBookmarkName = `promptDialog -q -tx`;
- rename $oldBookmarkName $newBookmarkName;
- setEdBookmarkUpdate $setEd;
- }
- }
-
- global proc setEdBookmarkRenameCallback(string $setEd)
- //
- // Callback for renaming set editor bookmarks.
- // (invoked by double clicking in editor)
- //
- {
- string $oldBookmarkName = getSelectedBookmark($setEd);
- setEdBookmarkRenameMenuCallback($setEd, $oldBookmarkName);
- }
-
-
- global proc setEdBookmarkAddCallback(string $setEd, string $renameWhen)
- //
- // Callback for adding set editor bookmarks.
- //
- {
- if ($renameWhen == "first")
- {
- string $result = `promptDialog
- -title "Name Bookmark"
- -message "Name Bookmark:"
- -text "Bookmark Name"
- -defaultButton "OK"
- -button "OK"
- -button "Cancel"`;
- if ($result == "OK")
- {
- string $newBookmarkName = `promptDialog -q -tx`;
- setEditor -edit -createBookmark $newBookmarkName $setEd;
- setEdBookmarkUpdate $setEd;
- }
- } else
- {
- setEditor -edit -createBookmark bookmark $setEd;
- setEdBookmarkUpdate $setEd;
- }
- }
-
- global proc setEdBookmarkEditor(string $setEd)
- {
- // Unique name for the window
- string $bmeWindow = ($setEd + "BMEDWindow");
-
- if (`window -exists $bmeWindow`)
- {
- showWindow $bmeWindow;
- setEdBookmarkUpdate $setEd;
- }
- else
- {
- setEdBookmarkCreateUI $setEd;
- }
- }
-
-
-